<?php
/**
 * Klasse zum erstellen einer Ordered-List
 *
 * @author		Joachim Ruf, Loresoft Software (http://www.loresoft.de)
 * @license		New BSD License
 * @version		Class for Bootstrap v2.3.2
 *
 * */


Class Bootstrap_List_Ordered_Handler
{
	private $arrEntry			= array();
	private $class				= NULL;


	/**
	 * @param string $_class	: Class
	 * */
	function __construct ($_class = NULL) {
		$this->class	= $_class;
	}


	/**
	 * Liefert eine Zeile zurueck.
	 * @param int $_size		: Breite {1-12}
	 * @param string $_content	: Auszugebender Content
	 * @return Bootstrap_Grid_Row
	 * */
	public function addEntry ($_content, array $_arrParam = array()) {
		return $this->arrEntry[] = new Bootstrap_List_Entry($_content, $_arrParam);
	}


	/**
	 * Liefert eine Zeile zurueck.
	 * @param int $i	: Auszugebende Zeile
	 * @return Yapary_Form_Formular_Row
	 * */
	public function get ($i) {
		if (!isset($this->arrEntry[$i])) {
			return NULL;
		}

		return $this->arrEntry[$i];
	}


	/**
	 * @desc Liefert alle Zeilen zurueck.
	 * @return Yapary_Form_Formular_Row[]
	 * */
	public function getList () {
		return $this->arrEntry;
	}


	/**
	 * Loescht einen Eintrag.
	 * @param string $id	: Zu loeschender Eintrag
	 * @return bool
	 * */
	public function delete ($i) {
		if (!isset($this->arrEntry[$i])) {
			return false;
		}

		unset($this->arrEntry[$i]);
		return true;
	}


	/**
	 * @desc Gibt das Grid aus.
	 * @return string
	 * */
	public function display() {
		$result	= NULL;
		$class	= NULL;
		if ($this->class !== NULL) {
			$class	= ' class="'.$this->class.'"';
		}

		if (count($this->arrEntry)) {
			/* @var $oRow Bootstrap_List_Entry */
			foreach ($this->arrEntry as $key => $oRow) {
				$result .=	$oRow->display();
			}
		}

		return '<ol'.$class.'>
					'.$result.'
				</ol>';
	}


}


?>